﻿@model Comment
@{  
    string ip = HttpContext.Current.Request.UserHostAddress;
    string userName = HttpContext.Current.Request.IsAuthenticated ? HttpContext.Current.User.Identity.Name : ip;
    bool isadded = (ViewData["Success"] != null) ? ((bool)ViewData["Success"]) : false;
}
<input id="isCommentAdded" type="hidden" value="@isadded" />
<table style="width: 100%;">
    <tr>
        <td colspan="2">
            @Html.ValidationSummary()
        </td>
    </tr>
    @if (!Request.IsAuthenticated)
    {
        <tr>
            <td colspan="2">
                @Html.ValidationSummary()
            </td>
        </tr>
        <tr>
            <td>
                @Html.Global("Publishing", "Name"):
            </td>
            <td>
                @Ajax.DnaFor().TextBox(m => m.UserName).HtmlAttributes(Html.GetUnobtrusiveValidationAttributes("UserName")).GetHtml()
            </td>
        </tr>
        <tr>
            <td>
                @Html.Global("Publishing", "Email"):
            </td>
            <td>
                @Ajax.DnaFor().TextBox(m => m.Email).HtmlAttributes(Html.GetUnobtrusiveValidationAttributes("Email")).GetHtml()
                @{Html.ValidateFor(m => m.Email); }
            </td>
        </tr>
        <tr>
            <td>
                @Html.Global("Publishing", "WebSite"):
            </td>
            <td>
                @Ajax.DnaFor().TextBox(m => m.WebSite).HtmlAttributes(Html.GetUnobtrusiveValidationAttributes("WebSite")).GetHtml()
            </td>
        </tr>
    }
    else
    {
        <tr>
            <td style="width: 100px;">
                @Html.Global("Publishing", "Name"):
            </td>
            <td>
                @(!string.IsNullOrEmpty(Context.Profile["DisplayName"] as string) ? Context.Profile["DisplayName"].ToString() : userName)
                <input type="hidden" value="@userName" name="Comment.UserName" />
            </td>
        </tr>
        <tr>
            <td>
                @Html.Global("Publishing", "Email"):
            </td>
            <td>
                @{ var email = Membership.GetUser(userName).Email;
                }
                @email
                <input type="hidden" value="@email" name="Comment.Email" />
            </td>
        </tr>
        <tr>
            <td>
                @Html.Global("Publishing", "WebSite"):
            </td>
            <td>
                @Context.Profile["WebSite"]
                <input type="hidden" value="@Context.Profile["WebSite"]" name="Comment.WebSite" />
            </td>
        </tr>
    }
    @*    <tr>
        <td colspan="3">
            @ReCaptcha.GetHtml(theme: "clean", publicKey: System.Web.Configuration.WebConfigurationManager.AppSettings["ReCaptchaPublicKey"])
        </td>
    </tr>*@
    <tr>
        <td colspan="2">
            @Html.AntiForgeryToken()
            <div>@Html.Global("publishing", "Comment"):</div>
            @{
                Ajax.Dna().RichTextBox("Comment.Body")
                    .AllowHTMLEditing(false)
                    .ToolPanes(panes =>
                    {
                        panes.Clear();
                        panes.Add().AddSimpleFontTools().AddParagraphTools();
                    })
                    .Render();
            }
            @*   @Ajax.Dna().TextArea("Body").Width(500).Height(200).Resizable().GetHtml()
            @{ Html.ValidateFor(m => m.Body); }*@
        </td>
    </tr>
    <tr>
        <td colspan="2" style="text-align: center;">
            @Ajax.Dna().Button("bntPostComment").Click("$(\"#Comment_Body\").richtextbox(\"syncContent\",\"source\");$(this).closest('form').submit();").LocText("Post").ImageIcons(Url.Content("~/content/images/icon_save.gif")).GetHtml()
        </td>
    </tr>
</table>
@Html.StartupScripts()
